package com.example.demo.controller;

import com.example.demo.ao.CommentAo;
import com.example.demo.service.CommentService;
import com.example.demo.vo.CommentVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/comment")
@Slf4j
public class CommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping("add/comments")
    public int addComment(@RequestBody CommentAo commentAo) {
        return commentService.insertComment(commentAo);
    }

    @PostMapping("comment/info")
    public List<CommentVo> selectAllComments(@RequestBody CommentAo commentAo) {
        return commentService.selectVideoById(commentAo);
    }
}
